<template>
    <div class="app-container">
        <div class="backgroundClass">
            <div class="titleBox">
                <el-page-header @back="()=>{this.$router.push('/simulation/index')}" :content="Mysjlist.title_name+' - 我的试卷'">
                </el-page-header>
            </div>
            <div>
                <el-table
                    :data="Mysjlist.list"
                    :border='false'
                    :height='"calc(100vh - 198px)"'
                    style="width: 100%;" 
                    :header-cell-style="{background:'#FAFAFA'}"
                    v-loading='loading'
                    >
                    <el-table-column
                        label="考试名称"
                        >
                        <template slot-scope="{ row }">
                            <span>{{row.title.split('/')[1]+"-"+Mysjlist.title_name}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="score"
                        label="得分"
                        >
                        <template slot-scope="{row}"> 
                            {{row.score}}分
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="答题时长">
                        <template slot-scope="{row}">
                            {{row.use_time>60?parseInt(row.use_time/60)+'分'+parseInt(row.use_time%60)+'秒':row.use_time+'秒' }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="create_time"
                        label="考试时间">
                    </el-table-column>
                    <el-table-column
                        label="查卷">
                        <template slot-scope="{ row }">
                            <el-button @click="fj(row)" type="primary">复卷</el-button>
                            <el-button type="danger" @click="ct(row)">查看错题</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
    </div>
</template>

<script>
import{mockRedo,getwrongbymockid}from'@/api/admin.js'
import { getapplyid } from "@/utils/auth";
export default {
    data() {
        return {
            Mysjlist:this.$store.state.questions.Mysjlist,
            loading:false,
        }
    },
    created() {
        console.log(this.Mysjlist)
    },
    methods: {
        fj(row){
            this.loading=true
            mockRedo({mockid:row.id,zujuan:row.form=='人工组卷'?1:''}).then(res=>{
                this.loading=false
                if(res.code==200){
                    this.$store.commit('SET_TI',res.data.list)
                    this.$router.push('/simulationExam?mockid='+res.data.mockid+'&gz=fj')
                }
            })
        },
        ct(row){
            this.loading=true
            getwrongbymockid({mockid:row.id,subjectid:row.subjectid, applyid: getapplyid()}).then(res=>{
                this.loading=false
                if(res.code==200){
                    if(res.data.length!=0){
                        this.$store.commit('SET_TI',res.data)
                        this.$router.push('/simulationExam?mockid='+res.data.mockid+'&gz='+row.gz+'&usererror=错题')
                    }else{
                        this.$message.error('改试卷没有错题')
                    }
                }
            })
        }
    },
}
</script>

<style lang="scss" scoped>
@import '~@/styles/utis.scss';
.titleBox{
    display: flex;
    min-width: 500px;
    border-bottom: 1px solid #EEEEEE;
    padding-bottom:24px;
}
::v-deep{
    .el-table{
        .el-table__body-wrapper{
            height:100% !important;
        }
    }
}
</style>